import 'package:flutter/material.dart';
import 'package:local_coffee/components/rgba.dart';
import 'package:local_coffee/pages/toolbar/order/widgets/order_list_row.dart';
import 'package:local_coffee/routes/index.dart';

class Order extends StatefulWidget {
  
  static _OrderState _orderState;

  getAppBar() {
    return _orderState.createAppBar();
  }

  Order() {
    _orderState = _OrderState();
  }

  @override
  _OrderState createState() => _OrderState();
}

class _OrderState extends State<Order> with TickerProviderStateMixin {
  
  static TabController _tabController;

  static List<Tab> tabs = [
    Tab(
      text: '全部',
    ),
    Tab(
      text: '未完成',
    ),
    Tab(
      text: '已完成',
      // icon: icon0xe600(
      //   color: RGBA.rgba7beaff
      // ),
    )
  ];

  @override
  void initState() {
    super.initState();
  }

  /// 创建 AppBar
  AppBar createAppBar() {
    _tabController = TabController(
      vsync: this,
      length: tabs.length
    );

    /// 配置 appBar
    return AppBar(
      centerTitle: true,
      title: Text(
        '订单列表',
        style: TextStyle(
          color: RGBA.rgba383838,
          fontSize: 18,
          fontWeight: FontWeight.bold
        ),
      ),
      bottom: PreferredSize(
        preferredSize: Size.fromHeight(44),
        child: Theme(
          data: ThemeData(
            splashColor: Colors.transparent,
            highlightColor: Colors.transparent
          ),
          child: TabBar(
            tabs: tabs,
            labelColor: RGBA.rgba88afd5,
            labelStyle: TextStyle(
              fontWeight: FontWeight.bold
            ),
            unselectedLabelStyle: TextStyle(
              fontSize: 15
            ),
            unselectedLabelColor: RGBA.rgba505050,
            controller: _tabController,
          ),
        ),
      ),
      backgroundColor: RGBA.rgbaffffff1,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: RGBA.rgbaf8f8f8,
      child: TabBarView(
        children: <Widget>[
          ListView(
            children: <Widget>[
              OrderListRow(
                1,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
                onPress: () => Navigator.pushNamed(
                  context, N.orderDetail,
                  arguments: {
                    "status": 
                  2}
                )
              ),
              OrderListRow(
                2,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
              OrderListRow(
                2,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
              OrderListRow(
                2,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
              OrderListRow(
                3,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
            ],
          ),
          ListView(
            children: <Widget>[
              OrderListRow(
                1,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
              OrderListRow(
                1,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
              OrderListRow(
                1,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
            ],
          ),
          ListView(
            children: <Widget>[
              OrderListRow(
                2,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
              OrderListRow(
                2,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
              OrderListRow(
                2,
                orderNum: '23847563928174',
                address: '北京市朝阳区青年汇佳园10号...',
                goodsName: '榛果拿铁',
                price: 20,
                time: '2020-03-20 12:12',
              ),
            ],
          ),
        ],
        controller: _tabController,
      ),
    );
  }
}